package com.rc.saas.mini.common.utils;

/**
 * Created by Sven on 2021/07/31
 */
public class CompTimeUtil {
    /**
     * 时分秒对比
     * @param s1
     * @param s2
     * @return
     */
    public static boolean compTime(String s1, String s2) {
        if (s1.indexOf(":") < 0 || s1.indexOf(":") < 0) {
            return false;
        } else {
            String[] array1 = s1.split(":");

            int total1 = 0;
            if (array1.length == 2) {
                total1 = Integer.valueOf(array1[0]) * 3600 + Integer.valueOf(array1[1]) * 60;
            } else {
                total1 = Integer.valueOf(array1[0]) * 3600 + Integer.valueOf(array1[1]) * 60 + Integer.valueOf(array1[2]);
            }
            String[] array2 = s2.split(":");

            int total2 = 0;
            if (array2.length == 2) {
                total2 = Integer.valueOf(array1[0]) * 3600 + Integer.valueOf(array1[1]) * 60;
            } else {
                total2 = Integer.valueOf(array1[0]) * 3600 + Integer.valueOf(array1[1]) * 60 + Integer.valueOf(array1[2]);
            }
            return total1 - total2 >= 0 ? true : false;
        }
    }
}
